﻿using HZU.ZP.Data.Interfaces;
using HZU.ZP.Data.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl
{
    public class CompayPictureDao : ICompayPictureDao
    {
        private EFCoreDbContext _context;
        public CompayPictureDao(EFCoreDbContext context)
        {
            _context = context;
        }
        public void Add(CompayPicture compayPicture)
        {
            _context.CompayPictures.Add(compayPicture);
            _context.SaveChanges();
        }

        public void Delete(int id)
        {
            var compayPicture = _context.CompayPictures.FirstOrDefault(e => e.Id == id);
            _context.CompayPictures.Remove(compayPicture);
            _context.SaveChanges();
        }

        public IList<CompayPicture> GetByCompanyId(int companyId)
        {
            return _context.CompayPictures.Where(e => e.CompanyId == companyId).ToList();
        }

        public void Updata(CompayPicture compayPicture)
        {
            _context.CompayPictures.Update(compayPicture);
            _context.SaveChanges();
        }
    }
}
